package com.example.demo.mvvm.ui.vm.fragment;

import android.databinding.ObservableField;
import android.view.View;
import android.widget.Toast;

import com.example.demo.mvvm.bean.UserBean;
import com.example.demo.mvvm.databinding.FragmentMeBinding;
import com.example.demo.mvvm.ui.activity.LoginActivity;
import com.example.demo.mvvm.ui.base.BaseViewVM;
import com.example.demo.mvvm.utils.ActivityUtils;
import com.example.demo.mvvm.utils.AppCacheSharedPreferences;
import com.example.demo.mvvm.utils.UserManager;

/**
 * Created by 80711 on 2018/5/23.
 */

public class MeFragmentVm extends BaseViewVM {
    private FragmentMeBinding binding;
    public ObservableField<UserBean> userBean = new ObservableField<>();

    public MeFragmentVm(FragmentMeBinding binding){
        this.binding = binding;
        userBean.set(UserManager.getUserBean());
    }

    public void gotoCollects(View view){
        if(AppCacheSharedPreferences.getCacheBoolean("IS_LOGIN" ,false) ){

        }else{
            ActivityUtils.push(ActivityUtils.peek() , LoginActivity.class);
        }
    }

    public void gotoAboutMe(View view){
        if(AppCacheSharedPreferences.getCacheBoolean("IS_LOGIN" ,false) ){

        }else{
            ActivityUtils.push(ActivityUtils.peek() , LoginActivity.class);
        }
    }

    public void signOut(View view){
        if(AppCacheSharedPreferences.getCacheBoolean("IS_LOGIN" ,false) ){
            Toast.makeText(ActivityUtils.peek(), "请先登录", Toast.LENGTH_SHORT).show();
        }else{
            ActivityUtils.push(ActivityUtils.peek() , LoginActivity.class);
        }
    }

}
